import axios from 'axios'

// 获取任务列表
export function fetchTaskList (data) {
  return axios({
    method: 'get',
    url: 'http://localhost:3001/data',
    params: data
  })
}

// 删除任务
export function delTaskList (id) {
  return axios({
    method: 'DELETE',
    url: `http://localhost:3001/data/${id}`
  })
}

// 新增任务
export function addTaskList (data) {
  return axios({
    method: 'POST',
    url: 'http://localhost:3001/data',
    data
  })
}

// 回显
export function showTaskList (id) {
  return axios({
    method: 'GET',
    url: `http://localhost:3001/data/${id}`
  })
}

// 编辑
export function updateTaskList (data) {
  return axios({
    method: 'PUT',
    url: `http://localhost:3001/data/${data.id}`,
    data
  })
}

// 搜索
export function searchTaskList (name) {
  return axios({
    method: 'GET',
    url: `http://localhost:3001/data/?name=${name}`
  })
}
